﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Meqs.Entity;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class TermInfoLogic : CommonLogic<TermInfo, int>, ITermInfoLogic
    {
        #region Implementation of ICommonLogic<TermInfo, int>

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(TermInfo entity)
        {
            return CreateObject(entity);
        }

        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(TermInfo entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public TermInfo FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<TermInfo> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<TermInfo> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion


        public IList<VClasssInfo> FindYearClasses(Hashtable ht)
        {
            try
            {
                string statementName = "TermInfo.FindYearClasses";
                return ExecuteQueryForList<VClasssInfo>(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }


        public IList<TermInfo> FindTermInfo(string schoolMark, int schoolYear, int term)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("SchoolYear", schoolYear);
            table.Add("Term", term);

            return FindCustomer<TermInfo>("TermInfo.FindTermInfo", table);
        }
    }
}
